// 定义 glTF 文件的类型

// glTF 文件的顶级结构
export interface GLTF {
    asset: GLTFAsset;
    scenes?: GLTFScene[];
    scene?: number;
    nodes?: GLTFNode[];
    meshes?: GLTFMesh[];
    buffers?: GLTFBuffer[];
    bufferViews?: GLTFBufferView[];
    accessors?: GLTFAccessor[];
    materials?: GLTFMaterial[];
    textures?: GLTFTexture[];
    images?: GLTFImage[];
    samplers?: GLTFSampler[];
    skins?: GLTFSkin[];
    animations?: GLTFAnimation[];
  }
  
  // 表示 glTF 文件中的元数据
  export interface GLTFAsset {
    version: string;
    generator?: string;
  }
  
  // 场景，由多个节点组成
  export interface GLTFScene {
    name?: string;
    nodes: number[];
  }
  
  // 节点，表示物体的层次结构
  export interface GLTFNode {
    name?: string;
    mesh?: number;
    children?: number[];
    translation?: [number, number, number];
    rotation?: [number, number, number, number];
    scale?: [number, number, number];
    matrix?: number[];
  }
  
  // 网格结构
  export interface GLTFMesh {
    name?: string;
    primitives: GLTFPrimitive[];
    weights?: number[];
  }
  
  // 组成网格的基本几何体（如三角形）
  export interface GLTFPrimitive {
    attributes: { [key: string]: number }; // POSITION, NORMAL, TEXCOORD_0 等
    indices?: number;
    material?: number;
    mode?: number; // 绘制模式（如 TRIANGLES）
  }
  
  // 顶点数据的缓冲区
  export interface GLTFBuffer {
    uri?: string;
    byteLength: number;
    name?: string;
  }
  
  // 缓冲区视图，指向 buffer 中的一部分
  export interface GLTFBufferView {
    buffer: number;
    byteOffset?: number;
    byteLength: number;
    byteStride?: number;
    target?: number; // 可以是 ARRAY_BUFFER 或 ELEMENT_ARRAY_BUFFER
    name?: string;
  }
  
  // 访问器，用于描述缓冲区中包含的矢量/矩阵数据
  export interface GLTFAccessor {
    bufferView: number;
    byteOffset?: number;
    componentType: number; // 数据类型（如 UNSIGNED_SHORT, FLOAT）
    normalized?: boolean;
    count: number;
    type: string; // SCALAR, VEC2, VEC3, VEC4, MAT2, MAT3, MAT4
    max?: number[];
    min?: number[];
    name?: string;
  }
  
  // 材质
  export interface GLTFMaterial {
    name?: string;
    pbrMetallicRoughness?: GLTFPBRMetallicRoughness;
    normalTexture?: GLTFTextureInfo;
    occlusionTexture?: GLTFTextureInfo;
    emissiveTexture?: GLTFTextureInfo;
    emissiveFactor?: [number, number, number];
    alphaMode?: string;
    alphaCutoff?: number;
    doubleSided?: boolean;
  }
  
  // PBR 材质
  export interface GLTFPBRMetallicRoughness {
    baseColorFactor?: [number, number, number, number];
    baseColorTexture?: GLTFTextureInfo;
    metallicFactor?: number;
    roughnessFactor?: number;
    metallicRoughnessTexture?: GLTFTextureInfo;
  }
  
  // 纹理信息
  export interface GLTFTextureInfo {
    index: number;
    texCoord?: number;
  }
  
  // 纹理
  export interface GLTFTexture {
    sampler?: number;
    source: number;
    name?: string;
  }
  
  // 图片
  export interface GLTFImage {
    uri?: string;
    mimeType?: string;
    bufferView?: number;
    name?: string;
  }
  
  // 纹理采样器
  export interface GLTFSampler {
    magFilter?: number;
    minFilter?: number;
    wrapS?: number;
    wrapT?: number;
    name?: string;
  }
  
  // 骨骼动画的蒙皮
  export interface GLTFSkin {
    inverseBindMatrices?: number;
    skeleton?: number;
    joints: number[];
    name?: string;
  }
  
  // 动画
  export interface GLTFAnimation {
    channels: GLTFChannel[];
    samplers: GLTFAnimationSampler[];
    name?: string;
  }
  
  // 动画的通道，定义了动画如何影响属性
  export interface GLTFChannel {
    sampler: number;
    target: GLTFChannelTarget;
  }
  
  // 动画的目标，如节点的平移、旋转、缩放等
  export interface GLTFChannelTarget {
    node: number;
    path: string; // translation, rotation, scale, or weights
  }
  
  // 动画采样器，包含输入/输出数据
  export interface GLTFAnimationSampler {
    input: number;
    interpolation?: string;
    output: number;
  }
  